<template>
	<div class="login-wrap">
		<div class="ms-login">
			<div class="ms-title">人工智能2D转3D工具</div>
			<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="ms-content">
				<el-form-item prop="username">
					<el-input v-model="ruleForm.username" placeholder="账号">
						<el-button slot="prepend" icon="el-icon-user"></el-button>
					</el-input>
				</el-form-item>
				<el-form-item prop="password">
					<el-input type="password" placeholder="密码" v-model="ruleForm.password"
						@keyup.enter.native="submitForm()">
						<el-button slot="prepend" icon="el-icon-unlock"></el-button>
					</el-input>
				</el-form-item>
				<div class="login-btn">
					<el-button type="primary" @click="submitForm()">登录</el-button>
				</div>
				<p class="login-tips">提示 : 请输入用户名和密码。</p>
			</el-form>
		</div>
		<vue-particles
		       color="#dedede"
		       :particleOpacity="0.7"
		       :particlesNumber="80"
		       shapeType="circle"
		       :particleSize="4"
		       linesColor="#dedede"
		       :linesWidth="1"
		       :lineLinked="true"
		       :lineOpacity="0.4"
		       :linesDistance="150"
		       :moveSpeed="3"
		       :hoverEffect="true"
		       hoverMode="grab"
		       :clickEffect="true"
		       clickMode="push"
		     >
		     </vue-particles>
		
	</div>
	
</template>

<script>
	export default{
		data(){
			return{
				ruleForm: {
					username: '',
					password: ''
				},
				rules: {
					username: [{
						required: true,
						message: '请输入用户名',
						trigger: 'blur'
					}],
					password: [{
						required: true,
						message: '请输入密码',
						trigger: 'blur'
					}]
				}
			}
		},
		methods:{
			// 点击登录按钮
			submitForm() {
				document.get
				let params = {
					username:this.ruleForm.username,
					api_key:this.ruleForm.password
				}
				if(params.username.length == 0){
			        return this.$message.error('账号不能为空')
			    }
				if(params.api_key.length == 0){
			        return this.$message.error('密码不能为空')
			    }

				this.$post(this.$api.homeLogin, params).then(res=>{
					console.log(res,'看看登录')
				    if (res.code == 0) {
				        // 存储用户的token
				        localStorage.setItem('username','zhangziyu');
				        localStorage.setItem('token',res.data.token);
				        this.$message.success('登录成功！');
				        this.$router.push('/');
				    }else{
				        this.$message.error(res.msg,10000);
				    }
				});
			},
		}
	}
</script>

<style scoped>
	.login-wrap {
		position: relative;
		width: 100%;
		height: 100%;
		/* background-image: url(../../assets/img/login-bg.jpg); */
		background-size: 100%;
		background-color: #000;
	}

	.ms-title {
		width: 100%;
		line-height: 50px;
		text-align: center;
		font-size: 20px;
		color: #000;
		border-bottom: 1px solid #ddd;
		color: #fff;
	}

	.ms-login {
		position: absolute;
		left: 44%;
		top: 50%;
		width: 500px;
		margin: -190px 0 0 -175px;
		border-radius: 5px;
		background: #000;
		opacity: 0.8;
		overflow: hidden;
		color: #fff;
		box-shadow: 0 0 20px 5px #6163eb;
	}

	.ms-content {
		padding: 30px 30px;
	}

	.login-btn {
		text-align: center;
	}

	.login-btn button {
		width: 100%;
		height: 36px;
		margin-bottom: 10px;
	}

	.login-tips {
		font-size: 12px;
		line-heigh: #000;
	}
</style>
